import ActorTypeUtil from "@/ActorTypeUtil";
import PlayerUtil from "@/PlayerUtil";
import ActorItemUtil from "@/ActorItemUtil";
import TextTagUtil from "@/TextTagUtil";

export default class 装备点击消耗金币升级 {


    constructor() {

        let actorType = ActorTypeUtil.getActorType("远古战斧(一级)");
        /**是否被动*/
        actorType.passive = false;
        let nextActorType = ActorTypeUtil.getActorType("远古战斧(二级)");
        actorType.describe = actorType.describe + "|n点击消耗" + nextActorType.goldCost + "金币升级到" + (nextActorType.name || nextActorType.id)
        actorType.onAction = (actor, x, y, targetUnit) => {

            let unit = actor.unit;
            if (PlayerUtil.costEnoughState(actor.unitOwner, nextActorType.goldCost, nextActorType.lumberCost)) {
                actor.destroy();
                let actorItem = ActorItemUtil.addActorItemForUnit(nextActorType.id, unit);
                TextTagUtil.textSuccess("升级成功:" + actorItem.getName(), unit);
            } else {
                TextTagUtil.textSuccess("金币不够!", unit);
            }


        }


    }


}